from userServer.models import UserDetail


def createUserDetail(userId,nickname,sex,age,phone,address,company,job,education,introduce):
    """创建用户信息"""
    #每个用户ID只能有一份信息，所以先判断是否存在
    if UserDetail.objects.filter(userId=userId).exists():
        return False
    userDetail = UserDetail(userId=userId,nickname=nickname,sex=sex,age=age,phone=phone,address=address,company=company,job=job,education=education,introduce=introduce)
    userDetail.save()
    return userDetail
def getUserDetail(userId):
    """"获取用户信息"""
    userDetail = UserDetail.objects.get(userId=userId)
    return userDetail
def updateUserDetail(userId,nickname,sex,age,phone,address,company,job,education,introduce):
    """修改信息"""
    userDetail = UserDetail.objects.get(userId=userId)
    userDetail.nickname = nickname
    userDetail.sex = sex
    userDetail.age = age
    userDetail.phone = phone
    userDetail.address = address
    userDetail.company = company
    userDetail.job = job
    userDetail.education = education
    userDetail.introduce = introduce
    userDetail.save()
    return userDetail